1. Field of the Invention
The present invention relates to a system for assisting a programmer in debugging a computer program to detect errors in the program logic.
2. Description of the Related Art
A computer source program is typically initially written in a high level computer language, also called source code, comprising descriptive statements of the actions the code will cause the computer to perform. High level computer languages include C++, FORTRAN, COBOL, JAVA.TM., etc. JAVA is a trademark of Sun Microsystems, Inc. A source program written in such a high level language must be converted into object or machine code, i.e., strings of zeros and ones, which the computer can execute to carry out the steps specified by the program. A compiler program is a computer program that receives as input source code and generates as output object code which may be loaded into the computer memory and executed.
FIG. 1 illustrates the compilation process. A compiler 2 receives as input a program in source code 4 and generates object code 6. The term "program" as used herein refers to the user program in any state, whether processed or unprocessed, from the high level language source code 4 form to the executable object code 6 form.
Oftentimes, the source code 4 will include "bugs." Bugs are logical errors in the original source code 4 that cause unexpected results during the execution of the object code 6. These unexpected results may cause the computer executing the object code 6 to generate unintended output and erroneous data, or terminate prematurely.
Compiler programs include a debugging feature that generates information that is used to diagnose bugs and errors in the source code. Before compiling source code 4, the user may set a debug option that causes the compiler 2 to generate an object code 6 file that includes debugging information and tables. A debugger program uses this debugging information during debugging operations. For instance in International Business Machine Corporation's (IBM.RTM.), the assignee of the subject patent application, VISUALAGE.RTM. for Cobol product, the user selects the TEST option before compiling the source program to generate the debugging information and tables. VISUALAGE and IBM are registered trademarks of International Business Machines, Corporation.
After compiling the source code 4 into executable object code 6, the user may run the debugger program and execute the object code 6 program in a debug mode. The debugger program provides a user interface programming tool that allows the user to control the execution of the program by executing only one program instruction at a time (single-stepping), determining the next instruction to be executed, examining and/or modifying computer register and memory locations, and setting breakpoints at particular locations within the program to stop execution of the program at the breakpoint. Preferably the breakpoint is set right before the error occurs to stop program execution and allow the user to take control through the debugger program and monitor the program's execution through the portion of code including the errors.
A breakpoint causes the program to cease executing at a certain point within the program. The user sets breakpoints with the debugger program user interface. The user can specify a breakpoint at: a particular line to stop execution when a specific line in the source code is reached; an entry to stop execution when an entry point is called; an address breakpoint to stop execution at a specific address; a storage change breakpoint to stop execution when data is written to a specified address; and a load occurrence breakpoint to stop execution when a Dynamic Link Library (DLL) file is loaded.
When executing the program and debugger program simultaneously, control may transfer to the debugger program upon processing the breakpoints in the program. Once the debugger program has control and program execution stops, the user can perform various debugging operations. For instance, upon reaching the breakpoint, the user can specify the display of certain expressions or values.
In interactive debugging systems, a graphical user interface may be used to allow the programmer to insert breakpoints within the source code with an input device such as a mouse. The user can examine the source code program in a graphical user interface and mouse "click" a location in the program to insert a breakpoint. The debugger will then execute the object code and display the original source code for the user to follow during the processing of the corresponding object code. Other systems allow the user to enter a breakpoint command on a command line to insert a specific breakpoint. After the program execution stops at a breakpoint, the user may then perform various debugging operations to check the value of variables, etc.
In prior art debugging systems, to set breakpoints for a specific program statement type, the user must locate the specific statement type in the program and then manually set the breakpoint for the located statement type. Moreover, in order to accommodate new breakpoint types, the compiler developer would have to modify the compiler code to change how the compiler generates debugging information during the compilation of the program.